<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//periksa di config/autoload.php
//autoload.php harus masuk daftar autoload
//periksa baris $autoload['model'] = array('eprocmodel');
class Eprocmodel extends CI_Model
{
	public function get_menu_for_level($level)
	{
		$this->db->from('menu');
		$this->db->like('menu_allowed','+'.$level.'+');
		$this->db->order_by('menu_id ASC');
		$result = $this->db->get();
		return $result;
	}
	function get_array_menu($id)
	{
		$this->db->select('menu_allowed');
		$this->db->from('menu');
		$this->db->where('menu_id',$id);
		$this->db->order_by('menu_nama ASC');
		$data = $this->db->get();
		if($data->num_rows() > 0)
		{
			$row = $data->row();
			$level = $row->menu_allowed;
			$arr = explode('+',$level);
			return $arr;
		}
		else
		{
			die();
		}
	}
	function get_all_hps()
	{
		//$this->db->from('eproc_hps');
		//$this->db->join('level','level_id=user_level','left');
		return $this->db->get('eproc_hps');
	}
	function get_all_level()
	{
		return $this->db->get('level');
	}
	function insert_data_hps($data)
	{
		$this->db->insert('eproc_hps',$data);
	}
	function get_hps_by_id($id)
	{
		$this->db->where('no_hps',$id);
		return $this->db->get('eproc_hps');
	}
	function update_data_hps($data,$id)
	{
		$this->db->where('no_hps',$id);
		$this->db->update('eproc_hps',$data);
	}
	function delete_user($id)
	{
		$this->db->where('no_hps',$id);
		$this->db->delete('eproc_hps');
	}

}